clear
set more off


* -----------------------------------------------------------
use "${final}/oisl_clean_data.dta", clear


foreach w in any 2 3 4 5 6 7 8 9 10{
	
	gen complete_plac_`w'  = (complete_`w' == 1 & treatment == 1)
	gen complete_treat_`w' = (complete_`w' == 1 & treatment == 2)

	gen complete_calc_plac_`w'  = (complete_calc_`w' == 1 /*
	*/						   &     treatment == 1)
	gen complete_calc_treat_`w' = (complete_calc_`w' == 1 /*
	*/						   &     treatment == 2)

}

destring id, replace
xtset id month

est clear
foreach comp in  any {
	// Main pitch (est6 to est10) (est16 to est20) (esto26 to est30)
	foreach var in any_mob sum_mob num_mob savings late_repayment{
		
		eststo: xtivreg `var' (complete_calc_plac_`comp' complete_calc_treat_`comp' /*
		*/	 					= treatment_2 treatment_3)	 /*
		*/					  `var'_base i.strata i.month $controls, /*
		*/					   vce(cluster id)
		estadd local Base "No" // Correct for savings and repayment
		quietly test complete_calc_plac_`comp' = complete_calc_treat_`comp'
		estadd scalar test = r(p)
		
	}
}


// Export results:


// any messages:
// Main pitch:
// Upstream outcomes:
esttab  using "${output}/robust_tot_any.tex"	/*
*/	   , replace sfmt(%12.3fc) number booktabs f b(3) se(3) label /*
*/	   star(* 0.1 ** 0.05 *** 0.01)							/*
*/	   depvars keep(complete_calc_plac_any complete_calc_treat_any) 										/*
*/	   coeflabel(complete_calc_plac_any  "Listened Savings " 		/*
*/				 complete_calc_treat_any "Listened MB " ) 				/*
*/	   mtitles("Any MoB" "Sum MoB" "No. MoB" "Savings (GHS)" "Late Repayment")   /*
*/	   collabels(none) compress 								/*
*/	   scalars("N Observations" "test p-Value Saving=MB" /*
*/				)

